<?php
unset($key);
unset($value);

echo $this->navegacion($this->nav);
$perfil = App_Perfil::getInstance();
$perfil->cargar("ADMIN_ROLES");
if ($perfil->crear()){
?>
<div align="right" class="buttons">
  <a class="btn btn-primary" href="<?php echo $this->baseUrl("/roles/index/crear");?>">
  <span class="glyphicon glyphicon-plus-sign"></span> Crear Rol</a>
</div>
<?php }
if(count($this->arrRoles)>0):?>
<table id="table_id" align="center" class="display">
  <thead>
    <tr>
      <th width="5%">Nro</th>
      <th width="20%">Roles</th>
      <th width="60%">Descripci&oacute;n</th>
      <th width="15%">Acciones</th>
    </tr>
  </thead>
  <tbody>
	<?php foreach ($this->arrRoles as $key => $value):?>
	<?php
//		$totalAsignado=0;
//		if(isset($arrCountUsuariosPorRol) && array_key_exists($value["codrol"],$arrCountUsuariosPorRol)) {
//		    $totalAsignado=$arrCountUsuariosPorRol[$value["codrol"]];
//		}
		$params=App_Util_SafeUrl::encriptar(array("codrol"=>$value["codrol"]),true);
		
	?>
    <tr>
      <td><?php echo ($key+1);?></td>
      <td><?php echo $value["nombrerol"];?></td>
      <td><?php echo $value["descripcion"];?></td>
      <td>
        <?php
        $tools = new App_Util_ToolButton();
        $tools->addEdit($this->baseUrl("/roles/index/modificar/{$params}"));
        $tools->add($this->baseUrl("/roles/index/perfilesrol/{$params}"), "Listado perfiles", "glyphicon glyphicon-user", $perfil->cargar("#ADMIN_USUARIOS_ACTIVAR"));
        $tools->addDelete($this->baseUrl("/roles/index/eliminar/{$params}"),$perfil->eliminar());
        echo $tools->render();
        ?>
      </td>
    </tr>
  <?php  endforeach;?>
  </tbody>
</table>

<script type="text/javascript">
 $(function() {
	$('#table_id').dataTable({
		"bJQueryUI": true,
		"bAutoWidth": false,
 		"sPaginationType": "full_numbers",
 		"bStateSave": true,
 		"aoColumns": [
 	 		 			{ "sType": "numeric" },
 	 		 			null,
 	 		 			null,
 	 		 			{ "bSortable": false, "bSearchable": false }
 	 		 		 ]
 	 		  		
	});
});
</script>
<?php else:?>
<br/>
<?php echo $this->mensajes("No existen registros");?>
<?php endif;?>
